package com.shisfish.utils;

import com.shisfish.enumeration.ResultEnum;
import com.shisfish.vo.ResultVO;

/**
 * @author shisfish
 * @date 2020/1/17
 */
public class ResultUtil {

    /**
     * 返回成功信息
     *
     * @param object
     * @return
     */
    public static ResultVO success(Object object) {
        ResultVO result = new ResultVO();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }

    /**
     * 返回成功信息
     *
     * @return
     */
    public static ResultVO success() {
        return success(null);
    }

    /**
     * 返回错误信息
     *
     * @param code
     * @param message
     * @return
     */
    public static ResultVO error(int code, String message) {
        ResultVO result = new ResultVO();
        result.setCode(code);
        result.setMsg(message);
        return result;
    }

}
